package com.cdut.hwadeefsc.service.impl;

import com.cdut.hwadeefsc.entity.scores;
import com.cdut.hwadeefsc.mapper.scoresMapper;
import com.cdut.hwadeefsc.service.scoresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class scoresServiceImpl implements scoresService {

    @Autowired
    private scoresMapper scoresMapper;

    // 修改studentId参数类型为Long（与实体类和Mapper保持一致）
    @Override
    public List<scores> getStudentScores(Long studentId) {
        return scoresMapper.findByStudentId(studentId);
    }

    // 修改studentId参数类型为Long（与实体类和Mapper保持一致）
    @Override
    public List<scores> getStudentScoresBySemester(Long studentId, String semester) {
        return scoresMapper.findByStudentIdAndSemester(studentId, semester);
    }

    @Override
    public boolean addScore(scores score) {
        return scoresMapper.insert(score) > 0;
    }

    @Override
    public boolean batchAddScores(List<scores> scores) {
        return scoresMapper.batchInsert(scores) > 0;
    }

    @Override
    public boolean updateScore(scores score) {
        return scoresMapper.update(score) > 0;
    }
}




